package com.tl.juc.c3;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class C4_InheritableThreadLocal_3 {
    public static void main(String[] args) throws InterruptedException {
        InheritableThreadLocal<String> threadLocal = new InheritableThreadLocal<>();
        threadLocal.set("test");

        ExecutorService executorService = Executors.newFixedThreadPool(5);
        for (int i=0;i<20;i++){
            if (i==10){
                threadLocal.set("test1");
            }
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    String value = threadLocal.get();
                    System.out.println("value:"+value);
                }
            });
        }
        Thread.sleep(1000);
    }
}
